#-*-coding:utf-8-*-
'''
minimalist implementation of zip command cat
'''
import os.path
import zipfile


def pzip(files,target):
    '''
    Compress list of files into archive target using ZIP method
    '''
    # create instance of zipfile in write mode
    nzip  = zipfile.ZipFile(target,mode="w",compression=zipfile.ZIP_DEFLATED)
    for f in files : # for each file, add it to archive
        nzip.write(f,os.path.basename(f))
    nzip.close() # closes archive

def punzip(archive):
    '''
    Uncompress the zip archive archive in current working directory
    '''
    nzip  = zipfile.ZipFile(archive,mode="r")
    for f in nzip.namelist():
        open(f,'w').write(nzip.read(f))

if __name__=='__main__':
    pzip(['/home/tclain/test.s','/home/tclain/etud2012.txt'],"test.zip")

